package com.bw1806.sellergoods.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.bw1806.mapper.TbPayLogMapper;
import com.bw1806.pojo.TbPayLog;
import com.bw1806.pojo.TbPayLogExample;
import com.bw1806.sellergoods.service.TbPayLogService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import entity.PageResult;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @描述
 * @创建人 wangyue
 * @创建时间2020/11/1115:02
 */
@Service(timeout = 5000,retries = 0)
public class TbPayLogServiceImpl implements TbPayLogService {

    @Autowired
    private TbPayLogMapper tbPayLogMapper;

    @Override
    public List<TbPayLog> findAll() {
        return tbPayLogMapper.selectByExample(null);
    }

    @Override
    public PageResult<TbPayLog> pagelist(TbPayLog tbPayLog,int pageNum,int pageSize) {

        PageHelper.startPage(pageNum, pageSize);

        TbPayLogExample example=new TbPayLogExample();

        TbPayLogExample.Criteria criteria = example.createCriteria();

        if(tbPayLog!=null){
            //if(tbPayLog.getName()!=null && tbPayLog.getName().length()>0){
            //    criteria.andNameLike("%"+tbPayLog.getName()+"%");
           // }
        }

        Page<TbPayLog> page= (Page<TbPayLog>) tbPayLogMapper.selectByExample(example);

        return new PageResult(page.getTotal(), page.getResult());
    }

    @Override
    public void save(TbPayLog tbPayLog) {
        String id = tbPayLog.getOutTradeNo();
       /* if(id !=null &&){
            tbPayLogMapper.updateByPrimaryKey(tbPayLog);
        } else{
            tbPayLogMapper.insert(tbPayLog);
        }*/
    }

    @Override
    public TbPayLog getById(String id) {
        return tbPayLogMapper.selectByPrimaryKey(id);
    }

    @Override
    public void deletebth(String[] ids) {
       for(String id : ids){
            tbPayLogMapper.deleteByPrimaryKey(id);
        }
        //tbPayLogMapper.deletebth(ids);
    }
}
